package com.fundcrawler.entity;

import lombok.*;
import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 基金净值记录实体
 */
@Entity
@Table(name = "fund_nav", 
       indexes = {
           @Index(name = "idx_date", columnList = "date"),
           @Index(name = "idx_fund_code_date", columnList = "fund_code, date", unique = true)
       }
//       ,uniqueConstraints = @UniqueConstraint(columnNames = {"fund_code", "date"})
)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode
public class FundNav {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "fund_code", length = 6, nullable = false, columnDefinition = "CHAR(6) COMMENT '基金编码'")
    private String fundCode;

    @Column(name = "fund_name", length = 32, nullable = true, columnDefinition = "VARCHAR(32) COMMENT '基金名称'")
    private String fundName;

    @Column(name = "date", nullable = false, columnDefinition = "DATE COMMENT '净值日期'")
    private LocalDate date;

    @Column(name = "unit_nav", precision = 10, scale = 4, columnDefinition = "DECIMAL(10,4) COMMENT '单位净值'")
    private BigDecimal unitNav;

    @Column(name = "accumulated_nav", precision = 10, scale = 4, columnDefinition = "DECIMAL(10,4) COMMENT '累计净值'")
    private BigDecimal accumulatedNav;

    @Column(name = "daily_growth", precision = 5, scale = 2, columnDefinition = "DECIMAL(5,2) COMMENT '日增长率'")
    private BigDecimal dailyGrowth;

    @Column(name = "purchase_status", length = 10, columnDefinition = "VARCHAR(10) COMMENT '申购状态'")
    private String purchaseStatus;

    @Column(name = "redemption_status", length = 10, columnDefinition = "VARCHAR(10) COMMENT '赎回状态'")
    private String redemptionStatus;

    @Column(name = "dividend", length = 50, columnDefinition = "VARCHAR(50) COMMENT '分红送配'")
    private String dividend;
}
